package com.ctint.petdida.adaptadores;

import java.util.LinkedList;

import com.ctint.petdida.R;
import com.ctint.petdida.clases.Veterinaria;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterVeterinaria extends ArrayAdapter<Veterinaria>{
	
	LayoutInflater inflater;
	LinkedList<Veterinaria> linked;

	public AdapterVeterinaria(Context context, int resource, int textViewResourceId, LinkedList<Veterinaria> linked) {
		super(context, resource, textViewResourceId, linked);
		this.inflater = LayoutInflater.from(context);
		this.linked = linked;
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		View row = convertView;
		Veterinaria currentVeterinaria = (Veterinaria)linked.get(position);
		
		if(row == null){
			row = inflater.inflate(R.layout.row_veterinaria, null);
		}
		
		//SET IMAGE VETERINARIA
		ImageView imageV = (ImageView) row.findViewById(R.id.imagen_veterinaria);	//Imagen Veterinaria
		imageV.setImageBitmap(currentVeterinaria.getImagen());
		imageV.setScaleType(ImageView.ScaleType.FIT_CENTER);
		
		//SET TEXT NOMBRE VETERINARIA
		TextView txtNombre = (TextView)row.findViewById(R.id.txt_nombre_veterinaria);
		txtNombre.setText(currentVeterinaria.getNombre());
		
		//SET TEXT DIRECCION VETERINARIA
		TextView txtDistancia = (TextView)row.findViewById(R.id.txt_distancia_veterinaria);
		txtDistancia.setText(currentVeterinaria.getDistancia());
		
		return row;
	}
}
